<%@ page language="java" contentType="text/html; charset=BIG5"
	pageEncoding="BIG5"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<script	src="http://localhost:8080/project/js/jquery.js"></script>
<script	src="http://localhost:8080/project/js/jquery-ui.js"></script>
<link rel="stylesheet" href="http://localhost:8080/project/css/style.css" />
<title>Package Create</title>
<script>
	$(document).ready(function() {
		$("input[name='startDate']").datepicker();
		$("input[name='endDate']").datepicker();
		$("input[name='add']").click(function() {
			$.post("http://localhost:8080/project/Product/DropDownProductList", function(data) {
				var output="";
				$(data).find("product").each(function() {
					var productname = $(this).find("productName").text();
					var productcode = $(this).find("productCode").text();
					output += "<option value='" + productname + "'>" + productcode + "</option>";
				});
				var output = "<select name='product'>" + output + "</select>\n<input type='text' name='quality' /><br/>";
				$("div[name='items']").append(output);
			});
		});
	});
</script>
</head>
<body>
	<form action="/project/Package/Create" method="post">
		Package Code<input type="text" name="packageId" /><br /> 
		Name<input type="text" name="packageName" /><br /> 
		Sales Price<input type="text" name="price" /><br /> 
		Start Date<input type="text" name="startDate" /><br /> 
		End Date<input type="text" name="endDate" /><br /> 
		Description<input type="text" name="description" /><br /> 
		Add product:		
		<div name="items">
			<select name="product">
				<c:forEach var="p" items="${products}">
					<option value="<c:out value="${p.productCode}" />"><c:out value="${p.productName}" /></option>
				</c:forEach>
			</select> 
			<input type="text" name="quality" /> <br/>
		</div>
		<input type="button" name="add" value="add" /> <br /> <input type="submit" />
	</form>
	<a href="/project/index">index</a>
</body>
</html>